Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

179
Visualizações
Why am I getting "Property 'wide' does not exist on type 'ThemedStyledProps<PressableProps & RefAttributes<View>, DefaultTheme>'."

I'm trying to add styled components to my project, but I'm having some trouble changing the style based on the props of the styled component. Whenever I try to do this - width: ${(props) => (props.wide ? '100%' : undefined)}; I get a Property 'wide' does not exist on type 'ThemedStyledProps<PressableProps & RefAttributes<View>, DefaultTheme>'. error.

I'm passing variant, wide and style to the styled component and I have the props type defined like this:

type StyledPressableProps = {
    variant?: ButtonVariant;
    wide?: boolean;
} & PressableProps;

But I'm still getting a TS error.

My code:

import React, { FunctionComponent } from 'react';
import { PressableProps, ViewStyle, StyleProp } from 'react-native';
import styled from 'styled-components/native';

import colors from '@src/core/colors';
import HeaderText from '../Text/HeaderText';

type ButtonVariant = 'primary' | 'secondary' | 'tertiary';

type Props = {
    title: string;
    variant?: ButtonVariant;
    wide?: boolean;
    style?: StyleProp<ViewStyle>;
} & Omit<PressableProps, 'style'>;

type StyledPressableProps = {
    variant?: ButtonVariant;
    wide?: boolean;
} & PressableProps;

const PrimaryButton: FunctionComponent<Props> = ({ title, variant = 'primary', wide = false, ...rest }) => {
    const textColor = variant === 'primary' ? colors.white : colors.primary600;

    return (
        <StyledPressable
            variant={variant}
            wide={wide}
            style={({ pressed: isPressed }) => [{ elevation: isPressed ? 5 : 0 }]}
            {...rest}
        >
            <StyledHeaderText variant="h4" style={{ color: textColor }}>
                {title}
            </StyledHeaderText>
        </StyledPressable>
    );
};

const StyledPressable: FunctionComponent<StyledPressableProps> = styled.Pressable`
    padding: 12px 24px;
    border-radius: 100px;
    border-width: 1.5px;
    justify-content: center;
    align-items: center;
    align-self: center;
    width: ${(props) => (props.wide ? '100%' : undefined)};
    background-color: ${(props) => styles[props.variant].backgroundColor};
    border-color: ${(props) => styles[props.variant].borderColor};
`;

const StyledHeaderText = styled(HeaderText)`
    text-align: center;
`;

const styles = {
    primary: {
        backgroundColor: colors.primary600,
        borderColor: colors.primary600,
    },
    secondary: {
        backgroundColor: colors.white,
        borderColor: colors.primary600,
    },
    tertiary: {
        backgroundColor: 'transparent',
        borderColor: 'transparent',
    },
};

export default PrimaryButton;
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda